Method: Sequel::Postgres::JSONBaseOp#[]
- Defined in:
- lib/sequel/extensions/pg_json_ops.rb
permalink #[](key) ⇒ Object Also known as: get
Get JSON array element or object field as json. If an array is given, gets the object at the specified path.
json_op[1] # (json -> 1)
json_op['a'] # (json -> 'a')
json_op[%w'a b'] # (json #> ARRAY['a', 'b'])
215 216 217 218 219 220 221 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 215 def [](key) if is_array?(key) json_op(GET_PATH, wrap_array(key)) else json_op(GET, key) end end |